﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace WonderfulSet
{
    class Card
    {
        private string shape;

        internal string Shape
        {
            get { return shape; }
            set { shape = value; }
        }
        private int number;

        public int Number
        {
            get { return number; }
            set { number = value; }
        }
        private Color color;

        public Color Color
        {
            get { return color; }
            set { color = value; }
        }
        private Brush shade;

        internal Brush Shade
        {
            get { return shade; }
            set { shade = value; }
        }
        private int i;

        public int I
        {
            get { return i; }
            set { i = value; }
        }

        public Card(string shape, Color color, Brush shade, int number)
        {
            this.color = color;
            this.number = number;
            this.shade = shade;
            this.shape = shape;
        }
        public void Draw(PictureBox pb)
        {
            
            //shape.Draw(pb);
            Bitmap myBMP;
            Graphics gr;
            Brush b = shade;
            Bitmap image1 = (Bitmap)Image.FromFile("striped.jpg");
            Bitmap image2 = (Bitmap)Image.FromFile("solid.jpg");
            
            Pen p = new Pen(color, 5);
            myBMP = new Bitmap(pb.Width, pb.Height);
            gr = Graphics.FromImage(myBMP);
            pb.Image = myBMP;
            Oval o = new Oval();
            if (shape == "rhomb")
            {
                Point p1 = new Point(93, 10);
                Point p2 = new Point(93, 75);
                Point p3 = new Point(46, 10);
                Point p4 = new Point(46, 75);
                Point p5 = new Point(140, 10);
                Point p6 = new Point(140, 75);
                Point p7 = new Point(36, 43);
                Point p8 = new Point(56, 43);
                Point p9 = new Point(83, 43);
                Point p10 = new Point(103, 43);
                Point p11 = new Point(130, 43);
                Point p12 = new Point(150, 43);
                Point[] rec1 = { p1, p9, p2, p10 };
                Point[] rec2 = { p3, p7, p4, p8 };
                Point[] rec3 = { p5, p11, p6, p12 };
                if (number == 1)
                {
                    gr.Clear(Color.White);
                    gr.DrawPolygon(p, rec1);
                    gr.FillPolygon(b, rec1);
                    pb.Image = myBMP;
                    gr.Dispose();
                }
                if (number == 2)
                {
                    gr.Clear(Color.White);
                    gr.DrawPolygon(p, rec2);
                    gr.DrawPolygon(p, rec3);
                    gr.FillPolygon(b, rec2);
                    gr.FillPolygon(b, rec3);
                    pb.Image = myBMP;
                    gr.Dispose();
                }
                if (number == 3)
                {
                    gr.Clear(Color.White);
                    gr.DrawPolygon(p, rec1);
                    gr.DrawPolygon(p, rec2);
                    gr.DrawPolygon(p, rec3);
                    gr.FillPolygon(b, rec1);
                    gr.FillPolygon(b, rec2);
                    gr.FillPolygon(b, rec3);
                    pb.Image = myBMP;
                    gr.Dispose();
                }
            }
           // gr.Dispose();
            if (shape == "oval")
            {
                if (number == 1)
                {
                    gr.Clear(Color.White);
                    gr.DrawEllipse(p, 83, 13, 20, 60);
                    gr.FillEllipse(b, 83, 13, 20, 60);
                    pb.Image = myBMP;
                    gr.Dispose();
                }
                if (number == 2)
                {
                    gr.Clear(Color.White);
                    gr.DrawEllipse(p, 53, 13, 20, 60);
                    gr.DrawEllipse(p, 116, 13, 20, 60);
                    gr.FillEllipse(b, 116, 13, 20, 60);
                    gr.FillEllipse(b, 53, 13, 20, 60);
                    pb.Image = myBMP;
                    gr.Dispose();
                }
                if (number == 3)
                {
                    gr.Clear(Color.White);
                    gr.DrawEllipse(p, 36, 13, 20, 60);
                    gr.DrawEllipse(p, 83, 13, 20, 60);
                    gr.DrawEllipse(p, 130, 13, 20, 60);
                    gr.FillEllipse(b, 36, 13, 20, 60);
                    gr.FillEllipse(b, 83, 13, 20, 60);
                    gr.FillEllipse(b, 130, 13, 20, 60);
                    pb.Image = myBMP;
                    gr.Dispose();
                }
            }
            if (shape == "curve")
            {
                Point p1 = new Point(35, 35);
                Point p2 = new Point(39, 50);
                Point p3 = new Point(33, 64);
                Point p4 = new Point(61, 54);
                Point p5 = new Point(57, 40);
                Point p6 = new Point(61, 23);
                Point p7 = new Point(80, 35);
                Point p8 = new Point(84, 50);
                Point p9 = new Point(78, 64);
                Point p10 = new Point(106, 54);
                Point p11 = new Point(102, 40);
                Point p12 = new Point(106, 23);
                Point p13 = new Point(125, 35);
                Point p14 = new Point(129, 50);
                Point p15 = new Point(123, 64);
                Point p16 = new Point(151, 54);
                Point p17 = new Point(147, 40);
                Point p18 = new Point(151, 23);
                Point[] rec1 = { p1, p2, p3, p4, p5, p6 };
                Point[] rec2 = { p7, p8, p9, p10, p11, p12 };
                Point[] rec3 = { p13, p14, p15, p16, p17, p18 };
                if (number == 1)
                {
                    gr.Clear(Color.White);
                    gr.DrawClosedCurve(p, rec2);
                    gr.FillClosedCurve(b, rec2);
                    pb.Image = myBMP;
                    gr.Dispose();
                }
                if (number == 2)
                {
                    gr.Clear(Color.White);
                    gr.DrawClosedCurve(p, rec1);
                    gr.FillClosedCurve(b, rec1);
                    gr.DrawClosedCurve(p, rec3);
                    gr.FillClosedCurve(b, rec3);
                    pb.Image = myBMP;
                    gr.Dispose();
                }
                if (number == 3)
                {
                    gr.Clear(Color.White);
                    gr.DrawClosedCurve(p, rec1);
                    gr.FillClosedCurve(b, rec1);
                    gr.DrawClosedCurve(p, rec2);
                    gr.FillClosedCurve(b, rec2);
                    gr.DrawClosedCurve(p, rec3);
                    gr.FillClosedCurve(b, rec3);
                    pb.Image = myBMP;
                    gr.Dispose();
                }

            }
            pb.Tag = this;
        }
    }
}
